#ifndef Q_OS_WIN
#include <windows.h>
#endif
#include "moneyconvertertest.h"
#include <common/logger/logger.h>
MoneyConverterTest::MoneyConverterTest(QObject* parent) : QObject(parent)
{
}

void MoneyConverterTest::testcvtNumber2RMB()
{
	// === string 输入 ===
	QCOMPARE(MoneyConverter::cvtNumber2RMB("0"), "零元整");
	QCOMPARE(MoneyConverter::cvtNumber2RMB("5"), "伍元整");
	QCOMPARE(MoneyConverter::cvtNumber2RMB("10"), "壹拾元整");
	QCOMPARE(MoneyConverter::cvtNumber2RMB("101"), "壹佰零壹元整");
	QCOMPARE(MoneyConverter::cvtNumber2RMB("1001"), "壹仟零壹元整");
	QCOMPARE(MoneyConverter::cvtNumber2RMB("10000"), "壹万元整");
	QCOMPARE(MoneyConverter::cvtNumber2RMB("1000001"), "壹佰万零壹元整");
	QCOMPARE(MoneyConverter::cvtNumber2RMB("123456789"), "壹亿贰仟叁佰肆拾伍万陆仟柒佰捌拾玖元整");
	QCOMPARE(MoneyConverter::cvtNumber2RMB("100.01"), "壹佰元零壹分");
	QCOMPARE(MoneyConverter::cvtNumber2RMB("100.10"), "壹佰元壹角");
	QCOMPARE(MoneyConverter::cvtNumber2RMB("100.11"), "壹佰元壹角壹分");
	QCOMPARE(MoneyConverter::cvtNumber2RMB("10000000000000000"), "溢出");// 超过范围

	LOG_DEBUG(MoneyConverter::cvtNumber2RMB("aad1"));
	LOG_DEBUG(MoneyConverter::cvtNumber2RMB("1000a"));
	LOG_DEBUG(MoneyConverter::cvtNumber2RMB("-500.01"));

	LOG_DEBUG(MoneyConverter::cvtNumber2RMB("10000000000000.01"));// 边界
	LOG_DEBUG(MoneyConverter::cvtNumber2RMB("999999999999.99"));

	// === double 输入 ===
	QCOMPARE(MoneyConverter::cvtNumber2RMB(0.0), "零元整");
	QCOMPARE(MoneyConverter::cvtNumber2RMB(8.08), "捌元零捌分");
	QCOMPARE(MoneyConverter::cvtNumber2RMB(20.2), "贰拾元贰角");
	QCOMPARE(MoneyConverter::cvtNumber2RMB(305.05), "叁佰零伍元零伍分");
	QCOMPARE(MoneyConverter::cvtNumber2RMB(1234.56), "壹仟贰佰叁拾肆元伍角陆分");
	QCOMPARE(MoneyConverter::cvtNumber2RMB(1001001.01), "壹佰万零壹仟零壹元零壹分");
	LOG_DEBUG(MoneyConverter::cvtNumber2RMB(9999999999999.99));// 边界
	LOG_DEBUG(MoneyConverter::cvtNumber2RMB(10000000000000.00));
	LOG_DEBUG(MoneyConverter::cvtNumber2RMB(10000000000000.01));
	QCOMPARE(MoneyConverter::cvtNumber2RMB("0"), "零元整");

}


int main(int argc, char* argv[])
{
#ifdef Q_OS_WIN
	// 设置控制台输出代码页为 UTF-8
	SetConsoleOutputCP(CP_UTF8);
	// 可选：设置控制台输入为 UTF-8
	SetConsoleCP(CP_UTF8);
#endif

	MoneyConverterTest tc;
	return QTest::qExec(&tc, argc, argv);// qExec 会把失败信息打印到 stdout
}